class Car:
    wheel = 4

    def driner(self):
        print('跑得快')


car = Car()
print(car.wheel)
car.driner()


'''
----封装案例：学生类----
编写一个学生类：
属性：姓名、性别、类别默认为people
方法：hello
封装属性：年龄
增加方法：显示年龄、设置年龄
'''
class student:
    category = 'people'

    def __init__(self, name, sex):
        self.name = name
        self.sex = sex

    def hello(self):
        print(f'大家好，我的名字叫做{self.name},性别{self.sex}')


z = student('张三', '男')
print(z.category)
z.hello()

'''
----案例：QQ群类----
编写一个QQ群类：
属性：群号、群名、成员、群暗号
方法：显示群号、显示群名、显示群成员、出示群暗号、添加群成员、移除群成员
'''


class QQGroup:
    def __init__(self, number, name, members, password):
        self.number = number
        self.name = name
        self.members = members
        self.password = password

    def qq_group_number(self):
        print("群号：", self.number)

    def qq_group_name(self):
        print('群名：', self.name)

    def qq_group_members(self):
        print('成员：', self.members)

    def qq_group_password(self):
        pwd = input('请出示你的暗号：')
        if pwd == self.password:
            print('暗号正确')
        else:
            print('暗号错误')

    def add_group_members(self, new_members):
        self.members.append(new_members)
        print('成员添加成功')

    def remove_group_members(self, remove_members):
        if remove_members in self.members:
            self.members.remove(remove_members)
            print('成员移除成功')
        else:
            print("查询不到此成员")


group_members_join = ['张三', '李四', '王五']
qq_group = QQGroup("123456789", "lalala", group_members_join, "lululu")

qq_group.qq_group_number()
qq_group.qq_group_name()
qq_group.qq_group_members()
qq_group.qq_group_password()

qq_group.add_group_members('六六六')
qq_group.qq_group_members()

qq_group.remove_group_members('李四')
qq_group.qq_group_members()
